package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

/**
 * 员工考核
 *
 * @author ytche
 * @date 2017年6月28日
 *
 */
@Entity
@JsonApiResource(type = "assessment")
@Table(name = "tnb_assessment")
public class Assessment extends BaseEntity {

	private static final long serialVersionUID = 1L;
	private Integer createTime;
	private String name; // 名称
	private Employee examOfficer;// 打分人
	private Employee examiner;// 考核对象
	private Integer point;// 分数
	private String remark;// 备注
	private Integer examTime;// 考核时间
	private Dicttype type;// 考核类型
	private Set<AssessmentIndicatorResult> results;
	private AssessmentIndicator indicatorType;// 考核细项分类

	private User examOfficerUser;// 打分人(用户)

	@Column(name = "create_time")
	public Integer getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Integer createTime) {
		this.createTime = createTime;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "point")
	public Integer getPoint() {
		return point;
	}

	public void setPoint(Integer point) {
		this.point = point;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "exam_officer_id")
	public Employee getExamOfficer() {
		return examOfficer;
	}

	public void setExamOfficer(Employee examOfficer) {
		this.examOfficer = examOfficer;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "exam_officer_user_id")
	public User getExamOfficerUser() {
		return examOfficerUser;
	}

	public void setExamOfficerUser(User examOfficerUser) {
		this.examOfficerUser = examOfficerUser;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "examiner_id")
	public Employee getExaminer() {
		return examiner;
	}

	public void setExaminer(Employee examiner) {
		this.examiner = examiner;
	}

	@Column(name = "exam_time")
	public Integer getExamTime() {
		return examTime;
	}

	public void setExamTime(Integer examTime) {
		this.examTime = examTime;
	}

	@OneToMany(mappedBy = "assessment", fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JsonApiToMany
	@JsonApiIncludeByDefault
	public Set<AssessmentIndicatorResult> getResults() {
		return results;
	}

	public void setResults(Set<AssessmentIndicatorResult> results) {
		this.results = results;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	@JoinColumn(name = "type")
	public Dicttype getType() {
		return type;
	}

	public void setType(Dicttype type) {
		this.type = type;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JsonApiToOne
	@JsonApiIncludeByDefault
	@JoinColumn(name = "indicator_type")
	public AssessmentIndicator getIndicatorType() {
		return indicatorType;
	}

	public void setIndicatorType(AssessmentIndicator indicatorType) {
		this.indicatorType = indicatorType;
	}
}
